package blue.mqtt4j.core.util;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

/**
 * @author Jin Zheng
 * @since 2020-10-07
 */
public class WaitUtil
{
	private WaitUtil()
	{
	}


	public static void await(CountDownLatch latch)
	{
		try
		{
			latch.await();
		}
		catch (InterruptedException e)
		{
			e.printStackTrace();
		}
	}

	public static void await(CountDownLatch latch, int timeout, TimeUnit timeUnit)
	{
		try
		{
			latch.await(timeout, timeUnit);
		}
		catch (InterruptedException e)
		{
			e.printStackTrace();
		}
	}

	public static void sleep(long millis)
	{
		try
		{
			Thread.sleep(millis);
		}
		catch (InterruptedException e)
		{
			e.printStackTrace();
		}
	}

}
